<?php
include('fonctionSQL.php');

//Inclusion du header de la page
include 'header.php';
?>
<script type="text/javascript" src="JS/verifCreationUtil.js"></script>
</head>

<body>

    <header id="header">
        <hgroup>
            <h1 class="site_title"><a href="index.html">Projet BIMSITE</a></h1>
            <h2 class="section_title">Edition de parcours de chasse au trésor</h2><div class="btn_view_site">
                <!--                            <a href="http://www.medialoot.com">View Site</a>-->
            </div>
        </hgroup>
    </header> <!-- end of header bar -->

    <section id="secondary_bar">
        <div class="user">
            <p> <?php
session_start();

// On teste si la variable de session existe et contient une valeur
if (empty($_SESSION['username'])) {
// Si inexistante ou nulle, on redirige vers le formulaire de login
    header('Location: identification.php');
    exit();
}
echo "" . $_SESSION['username'] . "   (";
echo "<a id='deconnexion' href='logout.php'>Deconnexion</a>)"
?></p>
            <!-- <a class="logout_user" href="#" title="Logout">Logout</a> -->
        </div>
        <div class="breadcrumbs_container">
            <article class="breadcrumbs"><a href="#">Liste des utilisateurs</a></article>
        </div>
    </section><!-- end of secondary bar -->

    <aside id="sidebar" class="column">
        <form class="quick_search">
            <input type="text" value="Quick Search" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;">
        </form>
        <hr/>
        <h3>Gestion Site</h3>
        <ul class="toggle">
            <li class="icn_new_article"><a href="creationSite.php">Création de site</a></li>
            <li class="icn_edit_article"><a href="#dialog" name="modal">Modification de site</a></li>               
        </ul>
        <h3>Utilisateurs</h3>
        <ul class="toggle">
            <li class="icn_add_user"><a href="ajouterUser.php">Ajout d'un utilisateur</a></li>
            <li class="icn_view_users"><a href="users.php">Liste des utilisateurs</a></li>
        </ul>
        <h3>Admin</h3>
        <ul class="toggle">
            <li class="icn_settings"><a href="#">Options</a></li>
            <li class="icn_security"><a href="#">Security</a></li>
            <li class="icn_jump_back"><a href="#">Logout</a></li>
        </ul>

        <footer>
        </footer>
    </aside><!-- end of sidebar -->

    <section id="main" class="column">

        <!--            <h4 class="alert_info">Welcome to the free MediaLoot admin panel template, this could be an informative message.</h4>-->

        <article class="module width_full">
            <header><h3 class="tabs_involved">Liste des utilisateurs</h3>

            </header>

            <div class="tab_container">
                <div id="tab3">
                    <!--        Liste des utilisateurs:-->
                    <table id="table_site" class="tablesorter" cellspacing="0"> 
                        <thead> 
                            <tr>
                                <th>Id</th>
                                <th>Nom</th>
                                <th>Pr&eacute;nom</th>
                                <th>Nom d'utilisateur</th>
                                <th>Actions</th>
                            </tr>
                        </thead>
                        <tbody> 
                            <?php
//On recupere les identifiants, les pseudos et les emails des utilisateurs
                            $db = connexion();
                            $sql = 'select id, nom, prenom, username from utilisateur';
                            $req = executer($sql);

                            while ($dnn = mysql_fetch_array($req)) {
                                ?>
                                <tr id="<?php echo $dnn['id']; ?>">
                                    <td id="U<?php echo $dnn['id']; ?>"><?php echo $dnn['id']; ?></td>
                                    <td><?php echo $dnn['nom']; ?></td>
                                    <td><?php echo $dnn['prenom']; ?></td>
                                    <td><a href="#"><?php echo htmlentities($dnn['username'], ENT_QUOTES, 'UTF-8'); ?></a></td>
                                    <td><a href='#' id="modif" name="modif" class='modif'><img src='images/icn_edit.png' alt='modifier'/></a>
                                        <a href='#' class='suppr'><img src='images/icn_trash.png' alt='supprimer'/></a></td>
                                </tr>
                                <?php
                            }
                            ?>
                        </tbody> 
                    </table>
                </div><!-- end of #tab1 -->
            </div>
        </article>

        <div class="spacer"></div>

    </section>

    <div id="boxes">

        <div id="dialog" class="window" id="dialog">
            <article class="module width_full">
                <header><h3>Liste des sites</h3></header>
                <div class="module_content">
                    <div>
                        <p>Choisissez un site</p>
                        <ul id="lienSite"></ul>
                    </div>
                </div>
                <footer>
                    <div class="submit_link">
                        <input type="submit" value="Annuler" class="close">
                        <a href="creationSite.php"><input type="submit" value="Nouveau site" class="alt_btn"></a>
                    </div>
                </footer>
            </article>
        </div>

        <!-- Masque pour masquer l'ensemble de l'écran -->
        <div id="mask"></div>

        <div id="modificationU" class="window">
            <article class="module width_full">
                <header><h3>Modification utilisateur</h3></header>
                <form id="modifU" class="form" title="Modification d'un utilisateur" action="#" method="post">
                    <div class="module_content">
                        <div class="div"><input type="hidden" id="idU" name="idU" value=""/><br /></div>
                        <fieldset>
                            <label for="nom">Nom</label>
                            <input type="text" id="nomM" name="nom" value=""/><br />
                        </fieldset>
                        <fieldset>
                            <label for="prenom">Pr&eacute;nom</label>
                            <input type="text" id="prenomM" name="prenom" value=""/><br />
                        </fieldset>
                        <fieldset>
                            <label for="username">Login</label>
                            <input type="text" id="usernameM" name="username" value=""/><br />
                        </fieldset>
                        <fieldset>
                            <label for="password">Mot de passe</label>
                            <input type="text" id="passwordM" name="password" /><br />
                        </fieldset>
                        <fieldset>
                            <label for="ecriture">Droit d'écriture</label>
                            <input type="checkbox" id="ecritureM" name="ecriture" value="" /><br />
                        </fieldset>
                        <fieldset>
                            <label for="lecture">Droit de lecture</label>
                            <input type="checkbox" id="lectureM" name="lecture" value="" />
                            <br />
                        </fieldset>
                        <footer>
                            <div class="submit_link">
                                <input type="submit" value="Modifier" class="alt_btn">
                                <input type="submit" value="Fermer" class="close">
                            </div>
                        </footer>
                    </div>
                </form>
            </article>
        </div>
    </div>
    
</body>
</html>
